﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
<Serializable()> Public Class Aermod

    Implements ICloneable
    Private m_SaveName As String = "未命名"
    Property SaveName() As String
        Get
            Return Me.m_SaveName
        End Get
        Set(ByVal value As String)
            Me.m_SaveName = value
        End Set
    End Property

    ''' <summary>
    ''' 控制对象
    ''' </summary>
    ''' <remarks></remarks>
    Private m_Control As New Control '控制类
    Private m_Source As New Source '污染源
    Private m_Receptor As New Receptor '网格和计算点
    Private m_BackCon As New BackCon '背景浓度
    Private m_MetSource As New MetSource '气象数据类
    Private m_OutPutOption As New OutPuts '输出选项类
    'Private m_AermodResults(-1) As AermodResultsPollute  '计算结果类
    Private m_Bprm As New Bpipprm '建筑物类
    Private m_AermodVersion As String = "09292" 'AERMOD DOS 程序的版本。因为07026和09292的版本有一点不一样，因此需要重新计算一下。
    ''' <summary>
    ''' Aermod是否已经计算过
    ''' </summary>
    ''' <remarks></remarks>
    Private m_IsRuned As Boolean = False
    ''' <summary>
    ''' 网格和计算点
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Receptor() As Receptor
        Get
            Return Me.m_Receptor
        End Get
        Set(ByVal value As Receptor)
            Me.m_Receptor = value
        End Set
    End Property
    ''' <summary>
    ''' 背景浓度
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property BackCon() As BackCon
        Get
            Return Me.m_BackCon
        End Get
        Set(ByVal value As BackCon)
            Me.m_BackCon = value
        End Set
    End Property
    Public Property MetSource() As MetSource
        Get
            Return m_MetSource
        End Get
        Set(ByVal value As MetSource)
            m_MetSource = value
        End Set
    End Property

    Public Property Control() As Control
        Get
            Return Me.m_Control
        End Get
        Set(ByVal value As Control)
            Me.m_Control = value
        End Set
    End Property

    Public Property Source() As Source
        Get
            Return Me.m_Source
        End Get
        Set(ByVal value As Source)
            Me.m_Source = value
        End Set
    End Property
    Public Property OutPutOption() As OutPuts
        Get
            Return Me.m_OutPutOption
        End Get
        Set(ByVal value As OutPuts)
            Me.m_OutPutOption = value
        End Set
    End Property
    '''' <summary>
    '''' 计算结果类数组，按污染物分类
    '''' </summary>
    '''' <value></value>
    '''' <returns></returns>
    '''' <remarks></remarks>
    'Public Property AermodResultsPollute() As AermodResultsPollute()
    '    Get
    '        Return Me.m_AermodResults
    '    End Get
    '    Set(ByVal value As AermodResultsPollute())
    '        Me.m_AermodResults = value
    '    End Set
    'End Property
    ''' <summary>
    ''' 建筑物类
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property Bprm() As Bpipprm
        Get
            Return Me.m_Bprm
        End Get
        Set(ByVal value As Bpipprm)
            Me.m_Bprm = value
        End Set
    End Property
    ''' <summary>
    ''' AERMOD DOS 程序的版本。因为07026和09292的版本有一点不一样，因此需要重新计算一下。
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property AermodVersion() As String
        Get
            Return Me.m_AermodVersion
        End Get
        Set(ByVal value As String)
            Me.m_AermodVersion = value
        End Set
    End Property
    ''' <summary>
    ''' Aermod是否已经计算过
    ''' </summary>
    ''' <remarks></remarks>
    Property IsRuned() As Boolean
        Get
            Return Me.m_IsRuned
        End Get
        Set(ByVal value As Boolean)
            Me.m_IsRuned = value
        End Set
    End Property


    Public Sub New()
        Me.m_BackCon.PolluteChaged(Me.m_Control.AllPolluts, Me.m_Receptor.DiscCarts)
    End Sub

    ''' <summary>
    ''' 输出控制流文件代码
    ''' </summary>
    ''' <param name="Index">被选中的污染物的序号，从0开始</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function OutPutAermod(ByVal Index As Integer, ByVal ProjID As String) As String

        Dim strP As String = ""
        strP = strP & Me.m_Control.OutPutContol(Index)


        strP = strP & Me.m_Source.OutPutSource(Me.m_Control, Index)
        ' ''小杨输出文件
        'Me.m_Source.HourSourceFile(Source.PolluteName, "kk", Source.StartDate, Source.Enddate)

        strP = strP & Me.m_Receptor.OutPutReceptor(Me.m_Control)
        strP = strP & Me.m_MetSource.OutPutMet
        strP = strP & Me.m_OutPutOption.OutPutOutPut(Me.m_Control, Index, Me.m_Source.Groups, ProjID)
        Return strP
    End Function

   

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim objCopy As New Aermod()

        objCopy.m_Control = Me.m_Control.Clone
        objCopy.m_Source = Me.m_Source.Clone
        objCopy.m_Receptor = Me.m_Receptor.Clone
        objCopy.m_BackCon = Me.m_BackCon.Clone
        objCopy.m_MetSource = Me.m_MetSource.Clone
        objCopy.m_OutPutOption = Me.m_OutPutOption.Clone '输出选项类
        objCopy.m_Bprm = Me.m_Bprm.Clone
        'ReDim objCopy.m_AermodResults(Me.m_AermodResults.Length - 1)
        objCopy.m_AermodVersion = Me.m_AermodVersion
        objCopy.m_IsRuned = Me.m_IsRuned
        Return objCopy
    End Function
   
End Class
